package com.hbnu.thread;

public class Consumer implements Runnable{

    private Box box = new Box();

    public Consumer(Box box) {
        this.box = box;
    }

    @Override
    public void run() {
        System.out.println("消费者开始取走产品");
        while (true) {
            try {
                Thread.sleep((int) Math.random() * 1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            box.getProduct();
        }
    }
}
